package lab01;

import java.util.Random;
import java.util.Scanner;

/**
 * Created by 星月 on 2017/10/8.
 */
public class Test08 {
    public static void main(String[] args) {
    Scanner n = new Scanner(System.in);
        System.out.println("请输入1-100的数");
    int number = (int) (Math.random() * 100) + 1;   //产生随机数
        for(int i = 1; i <=100; i++) {
        int j = n.nextInt();                       //猜测数
        if (j < number) {
            System.out.println("猜小了");
        }
        else if (j > number) {
            System.out.println("猜大了");
        }
        else {
            System.out.println("猜对了！");
            System.out.println("猜的次数为：" + i);
        }
    }
 }
}


